import { S } from '../../s';
import { IPSAppCodeList } from '../codelist/ipsapp-code-list';
import { IPSAppDEAction } from './ipsapp-deaction';
import { IPSAppDEDataSet } from './ipsapp-dedata-set';
import { IPSAppDELogic } from './ipsapp-delogic';
import { IPSAppDEMethod } from './ipsapp-demethod';
import { IPSAppDEMethodInput } from './ipsapp-demethod-input';
import { IPSAppDEMethodReturn } from './ipsapp-demethod-return';
import { IPSAppDataEntity } from './ipsapp-data-entity';
import { IPSDEDQCondition } from '../../dataentity/ds/ipsdedqcondition';
import { IPSDEDQGroupCondition } from '../../dataentity/ds/ipsdedqgroup-condition';
import { IPSSysPFPlugin } from '../../res/ipssys-pfplugin';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSAppDEMethodImpl
  extends PSModelObjectImpl
  implements IPSAppDEMethod, IPSAppDEAction, IPSAppDEDataSet
{
  protected adpsdedqconditions: IPSDEDQCondition[];
  getADPSDEDQConditions(): IPSDEDQCondition[] | null {
    return (
      this.adpsdedqconditions ||
      (this.adpsdedqconditions = this.fillChildListModel(
        this.M.getADPSDEDQConditions,
        S._39d,
      ) as IPSDEDQCondition[])
    );
  }

  get actionMode():
    | 'CREATE'
    | 'READ'
    | 'UPDATE'
    | 'DELETE'
    | 'CUSTOM'
    | 'GETDRAFT'
    | 'UNKNOWN'
    | 'MOVEORDER'
    | 'CHECKKEY'
    | 'USER'
    | 'USER2'
    | 'USER3'
    | 'USER4' {
    return this.M.actionMode;
  }

  get actionType():
    | 'USERCUSTOM'
    | 'DELOGIC'
    | 'BUILTIN'
    | 'SELECTBYKEY'
    | 'USERCREATE'
    | 'USERUPDATE'
    | 'USERSYSUPDATE'
    | 'SCRIPT'
    | 'REMOTE' {
    return this.M.actionType || 'REMOTE';
  }

  get afterCode(): string {
    return this.M.afterCode;
  }

  get batchActionMode(): 0 | 1 | 2 | 5 | 6 {
    return this.M.batchActionMode != null ? this.M.batchActionMode : 0;
  }

  get beforeCode(): string {
    return this.M.beforeCode;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get codeName2(): string {
    return this.M.codeName2;
  }

  get dataSetType():
    | 'DATAQUERY'
    | 'INDEXDE'
    | 'MULTIFORM'
    | 'CODELIST'
    | 'DELOGIC'
    | 'SCRIPT'
    | 'REMOTE' {
    return this.M.dataSetType || 'REMOTE';
  }

  get methodType():
    | 'DEACTION'
    | 'FETCH'
    | 'SELECT'
    | 'FETCHTEMP'
    | 'SELECTTEMP'
    | 'WFACTION'
    | 'FILTERACTION'
    | 'USER'
    | 'USER2'
    | 'USER3'
    | 'USER4' {
    return this.M.methodType;
  }

  protected psappcodelist: IPSAppCodeList;
  getPSAppCodeList(): IPSAppCodeList | null {
    return (
      this.psappcodelist ||
      (this.psappcodelist = this.fillObjectModel(
        S._8,
        this.M.getPSAppCodeList,
        S._2a2,
      ) as IPSAppCodeList)
    );
  }

  protected psappdelogic: IPSAppDELogic;
  getPSAppDELogic(): IPSAppDELogic | null {
    if (this.psappdelogic != null) return this.psappdelogic;
    const value = this.M.getPSAppDELogic;
    if (value == null) {
      return;
    }
    const ipsappdataentity = this.getParentPSModelObject(
      S._f,
    ) as IPSAppDataEntity;
    if (ipsappdataentity != null) {
      this.psappdelogic = ipsappdataentity.findPSAppDELogic(value);
    }
    return this.psappdelogic;
  }

  protected psappdemethodinput: IPSAppDEMethodInput;
  getPSAppDEMethodInput(): IPSAppDEMethodInput | null {
    return (
      this.psappdemethodinput ||
      (this.psappdemethodinput = this.fillObjectModel(
        S._3d0,
        this.M.getPSAppDEMethodInput,
        S._3d1,
      ) as IPSAppDEMethodInput)
    );
  }

  protected psappdemethodreturn: IPSAppDEMethodReturn;
  getPSAppDEMethodReturn(): IPSAppDEMethodReturn | null {
    return (
      this.psappdemethodreturn ||
      (this.psappdemethodreturn = this.fillObjectModel(
        S._3d2,
        this.M.getPSAppDEMethodReturn,
        S._3d3,
      ) as IPSAppDEMethodReturn)
    );
  }

  protected psdedqgroupconditions: IPSDEDQGroupCondition[];
  getPSDEDQGroupConditions(): IPSDEDQGroupCondition[] | null {
    return (
      this.psdedqgroupconditions ||
      (this.psdedqgroupconditions = this.fillChildListModel(
        this.M.getPSDEDQGroupConditions,
        S._3a2,
      ) as IPSDEDQGroupCondition[])
    );
  }

  findPSDEDQGroupCondition(objKey: any): IPSDEDQGroupCondition | null {
    return this.getPSModel5(
      S._3a2,
      this.getPSDEDQGroupConditions(),
      objKey,
    ) as IPSDEDQGroupCondition;
  }

  protected pssyspfplugin: IPSSysPFPlugin;
  getPSSysPFPlugin(): IPSSysPFPlugin | null {
    return (
      this.pssyspfplugin ||
      (this.pssyspfplugin = this.fillObjectModel(
        S._27c,
        this.M.getPSSysPFPlugin,
        S._2a7,
      ) as IPSSysPFPlugin)
    );
  }

  get predefinedType():
    | 'CODELIST'
    | 'INDEXDE'
    | 'MULTIFORM'
    | 'DELOGIC'
    | 'SCRIPT'
    | 'REMOTE' {
    return this.M.predefinedType;
  }

  get requestField(): string {
    return this.M.requestField;
  }
  protected requestfullpaths: string[];
  getRequestFullPaths(): string[] | null {
    if (this.requestfullpaths == null) {
      const value = this.M.requestFullPaths;
      if (value == null) {
        return null;
      }
      const arrayNode: any[] = value;
      if (arrayNode.length == 0) {
        return null;
      }
      const list: string[] = [];
      for (let i = 0; i < arrayNode.length; i++) {
        list.push(arrayNode[i]);
      }
      this.requestfullpaths = list;
    }
    return this.requestfullpaths;
  }

  get requestMethod():
    | 'GET'
    | 'HEAD'
    | 'POST'
    | 'PUT'
    | 'PATCH'
    | 'DELETE'
    | 'OPTIONS'
    | 'TRACE' {
    return this.M.requestMethod;
  }

  get requestParamType():
    | 'NONE'
    | 'FIELD'
    | 'FIELDS'
    | 'ENTITY'
    | 'ENTITIES'
    | 'OBJECT'
    | 'OBJECTS' {
    return this.M.requestParamType;
  }

  get requestPath(): string {
    return this.M.requestPath;
  }

  get scriptCode(): string {
    return this.M.scriptCode;
  }

  get tempDataMode(): 0 | 1 | 2 {
    return this.M.tempDataMode != null ? this.M.tempDataMode : 0;
  }

  get asyncAction(): boolean {
    return this.M.asyncAction != null ? this.M.asyncAction : false;
  }

  get builtinMethod(): boolean {
    return this.M.builtinMethod;
  }

  get customCode(): boolean {
    return this.M.customCode != null ? this.M.customCode : false;
  }

  get enableBatchAction(): boolean {
    return this.M.enableBatchAction != null ? this.M.enableBatchAction : false;
  }

  get enableTestMethod(): boolean {
    return this.M.enableTestMethod != null ? this.M.enableTestMethod : false;
  }

  get needResourceKey(): boolean {
    return this.M.needResourceKey != null ? this.M.needResourceKey : false;
  }

  get noServiceCodeName(): boolean {
    return this.M.noServiceCodeName != null ? this.M.noServiceCodeName : false;
  }
  get cls(): string {
    return 'PSAppDEMethodImpl';
  }
  instanceof(cls: string): boolean {
    if (cls == S._2 || cls == S._3 || cls == S._4) return true;
    return super.instanceof(cls);
  }
}
